package test.bean;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

public class TreeNode {
    private Integer id;
    private Integer parentId;
    private TreeNode parentNode;
    private List<TreeNode> childNodes;
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public Integer getParentId() {
        return parentId;
    }
    public void setParentId(Integer parentId) {
        this.parentId = parentId;
    }
    public TreeNode getParentNode() {
        return parentNode;
    }
    public void setParentNode(TreeNode parentNode) {
        this.parentNode = parentNode;
    }
    public List<TreeNode> getChildNodes() {
        return childNodes;
    }
    public void setChildNodes(List<TreeNode> childNodes) {
        this.childNodes = childNodes;
    }
    public void addChildNode(TreeNode treeNode){
        if(childNodes==null){
            childNodes = new ArrayList<>();
        }
        childNodes.add(treeNode);
    }
    @Override
    public String toString() {
        return "TreeNode [id=" + id + ", parentId=" + parentId + "]";
    }

}
